// pages/confirm/confirm.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:'',
    image:'',
    keshi:"",
    qian:"",
    shijain:"",
    dates:"",
    scoreList: [], //分数数组
     scoreArr: ["0分", "1分", "2分", "3分", "4分", "5分"],
     num: 0,
     hiddenmodalput: true,
     jiuzenren:"",
     phone:"",
     jiuzhenhao:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    var inw = JSON.parse(options.item)
    that.setData({                        
      qian:inw.qian,
      shijain:inw.shijain
     })
     wx.getStorage({
       key: 'asd',
       success(e){
         that.setData({
          keshi:e.data
         })
       }
     })
     wx.getStorage({
       key: 'image',
       success(e){
        that.setData({
          image:e.data
        })
      }
     })
     wx.getStorage({
       key: 'name',
       success(e){
        that.setData({
          name:e.data
        })
      }
     })
     wx.getStorage({
       key: 'dates',
       success(e){
        that.setData({
          dates:e.data
        })
      }
     })
  },

//点击按钮痰喘指定的hiddenmodalput弹出框
 
modalinput: function () {
  this.setData({
  hiddenmodalput: !this.data.hiddenmodalput
  })
  },//取消按钮
  cancel: function () {
  this.setData({
  hiddenmodalput: true
  });
  },
//确认
// confirm: function () {
//   this.setData({
//   hiddenmodalput: true
//   })
//   },  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  scoreChange(e) {
    var that = this;
    var tempList = that.data.scoreList;
    for (var i = 0; i < tempList.length; i++) {
      //找到所选的下拉框赋值
      if (tempList[i]["num"] == e.currentTarget.dataset.num) {
        tempList[i]["score"] = e.detail.value;
        break;
      }
    }
    //改变后的值赋值scoreList重新绑定
    that.setData({
      scoreList: tempList
    })
  },
   //添加一个列表
   confirm(e) {
    var that = this
    var addlist = this.data.scoreList;
    var obj = {
      score: null,
      num: this.data.num + 1
    }
    addlist.push(obj)
    wx.requestPayment({
      "timeStamp": "",
      "nonceStr": "",
      "package": "",
      "signType": "MD5",
      "paySign": "",
      "success":function(res){
      },
      "fail":function(res){
      }
   })
    that.setData({
      scoreList: addlist,
      num: this.data.num + 1,
      hiddenmodalput: true
    })
   
   
  },
  objectMove(e) {
    if (this.data.scoreList.length > 0) {
      this.data.scoreList.splice(this.data.scoreList.length - 1, 1);
      this.setData({
        scoreList: this.data.scoreList,
        num: this.data.num - 1,
      })
    }
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})